#ifndef SHM_H
#define SHM_H
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <sys/shm.h>
#include <string>

#define SHM_BUF_SIZE	128
using namespace std;
union semun
{
    int val;
    struct semid_ds *buf;
    unsigned short *array;
};

class Shm{
    public:
    string shm_read();
    int shm_init(int SHARE_KEY,int SIGNAL_KEY);
    int shm_write(string data);
    int remove_shm();

    private:
    int V();
    int P();
    int sem_id{-1};
    void *shm_addr{NULL};
    int shmid;
    struct sembuf sem_p{0, -1, 0};
    struct sembuf sem_v{0, 1, 0};

};

#endif
